package com.duqc.designpattern.decorator;

import com.duqc.util.AESUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName AESEncryptionDecorator
 * @Description 装饰者实现类
 * @Author duqc
 * @Date 2021/5/11
 **/
@Slf4j
public class AESEncryptionDecorator extends EncryptionDecorator {

    protected AESEncryptionDecorator(EncryptionBase encryptionBase) {
        super(encryptionBase);
    }

    @Override
    public String encrypt(String string, String password) {
        //首先调用父类的加密方法，得到父类的算法加密后的结果
        String encrypt = super.encrypt(string, password);
        log.info("使用AES加密");
        //得到的密文，再用AES算法加密，返回
        return AESUtil.encrypt(encrypt, password);
    }
}
